/* Copyright (c) 2010, Peter Lényi */
/* Licensed under The BSD License. */

package gem.apps.gfs2.engine.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Entity class Person encapsulates person's personal information.
 * 
 * @author Peter Lényi
 * @version 20100515F
 */
@Entity
public class Person implements Serializable
{
    /**
     * uid
     * pseudonym
     * registered
     * fileMeta
     * personalStyle
     */

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long            uid;
    private String          pseudonym;
    @Temporal(TemporalType.TIMESTAMP)
    private Date            registered;
    @OneToMany(mappedBy="owner")
    private List<FileMeta>  fileMeta;
    @OneToOne
    private Style           personalStyle;

    public Person() {}

    public List<FileMeta> getFileMeta() {
        return fileMeta;
    }

    public void setFileMeta(List<FileMeta> fileMeta) {
        this.fileMeta = fileMeta;
    }

    public Style getPersonalStyle() {
        return personalStyle;
    }

    public void setPersonalStyle(Style personalStyle) {
        this.personalStyle = personalStyle;
    }

    public String getPseudonym() {
        return pseudonym;
    }

    public void setPseudonym(String pseudonym) {
        this.pseudonym = pseudonym;
    }

    public Date getRegistered() {
        return registered;
    }

    public void setRegistered(Date registered) {
        this.registered = registered;
    }

    public Long getUid() {
        return uid;
    }

    public void setUid(Long uid) {
        this.uid = uid;
    }

    @Override
    public boolean equals(Object o) {
        boolean equal = false;
        if (o != null && o instanceof Person) {
            Person p = (Person) o;
            if (uid == p.uid) {
                equal = true;
            }
        }
        return equal;
    }

    @Override
    public int hashCode() {
        return uid.hashCode();
    }

    @Override
    public String toString() {
        return "GFS2:Person#" + uid;
    }
}
